
#include "TestResult.hpp"
#include "Failure.hpp"

#include <stdio.h>
#include <stdlib.h>

TestResult::TestResult ()
    : failureCount (0)
{
}

void TestResult::testsStarted ()
{
}


void TestResult::addFailure (const Failure& failure)
{
    fprintf(
      stdout,
      "%s:%ld: Failure: %s: \"%s\"\n",
      failure.fileName.asCharString (),
      failure.lineNumber,
      failure.testName.asCharString (),
      failure.message.asCharString ()
    );
    failureCount++;
}


void TestResult::testsEnded ()
{
    if (failureCount > 0)
    {
        fprintf (stdout, "\n <<< There were %ld failures!!! >>>\n\n", failureCount);
        exit (EXIT_FAILURE);
    }
    else
    {
        fprintf (stdout, "\n <<< There were no test failures >>> :) :) :)\n\n");
    }
}
